<%@ page language="java" import="java.util.*,com.css.vo.*" pageEncoding="UTF-8"%>
<%@ page import="com.css.dao.*,com.css.dao.impl.*"%>
<%@ page import="com.css.dao.*,com.css.action.*"%>
<%@ page import="com.css.dao.*,com.css.service.*"%>
<%@ page import="org.springframework.context.*,org.springframework.context.support.*"%>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="java.util.Date" %>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>新增销售订单</title>
  <link rel="stylesheet" href="./../styles.css">
</head>
<body>
  <header>
    <h1>新增销售订单</h1>
    <nav>
      <ul> 
      	<li><a href="./../index.jsp">主页</a></li>
        <li><a href="getList.action">系统管理</a></li>
        <li><a href="../Customer/customer-management.jsp">客户信息管理</a></li>
        <li><a href="../Car/car-management.jsp">汽车信息管理</a></li>
        <li><a href="../Employee/employee-management.jsp">员工信息管理</a></li>
        <li><a href="../Sale/sales-management.jsp">销售信息管理</a></li>
      </ul>
    </nav>
  </header>

<%

	ApplicationContext myaApplicationContext=new ClassPathXmlApplicationContext("applicationContext.xml");
  	ISaleService saleService = (ISaleService)myaApplicationContext.getBean("saleService");
  	ICarService carService = (ICarService)myaApplicationContext.getBean("carService");
  	ICustomerService customerService = (ICustomerService)myaApplicationContext.getBean("customerService");
  	IEmployeeService employeeService = (IEmployeeService)myaApplicationContext.getBean("employeeService");
 %>


  <div class="content">
    <h2>请输入销售信息</h2>
    <form action="addSale.action" method="post">
      <table>    
		<tr>
		  <td><label for="customer">客户：</label></td>
		  <td>
		    <select id="sale.customerId" name="sale.customerId" required>
		      <option value="">请选择客户</option>
		      <% 
		        List<Customer> customerList = customerService.findAllCustomer();
		        for (Customer customer : customerList) {
		      %>
		        <option value="<%= customer.getCustomerId() %>"><%= customer.getCustomerName() %></option>
		      <% 
		        }
		      %>
		    </select>
		  </td>
		</tr>

<tr>
  <td><label for="carId">汽车：</label></td>
  <td>
    <select id="sale.carId" name="sale.carId" required>
      <option value="">请选择汽车</option>
      <% 
        List<Car> carList = carService.findAllCar();
        for (Car car : carList) {
      %>
        <option value="<%= car.getCarId() %>"><%= car.getCarModel() + " " + car.getVersion() %></option>
      <% 
        }
      %>
    </select>
  </td>
</tr>

<tr>
  <td><label for="employeeId">员工：</label></td>
  <td>
    <select id="sale.employeeId" name="sale.employeeId" required>
      <option value="">请选择员工</option>
      <% 
        List<Employee> employeeList = employeeService.findAllEmployee();
        for (Employee employee : employeeList) {
      %>
        <option value="<%= employee.getEmployeeId() %>"><%= employee.getEmployeeName() %></option>
      <% 
        }
      %>
    </select>
  </td>
</tr>
		
        <tr>
          <td><label for="saleAmount">金额：</label></td>
          <td><input type="text" id="sale.saleAmount" name="sale.saleAmount" required></td>
        </tr>
        <tr>
          <td><label for="orderDate">订车日期：</label></td>
          <td><input type="date" id="sale.orderDate" name="sale.orderDate" step="0.01" required></td>
        </tr>
        <tr>
          <td><label for="deliveryDate">交付日期：</label></td>
          <td><input type="date" id="sale.deliveryDate" name="sale.deliveryDate"></td>
        </tr>
      </table>
      <br>
      <button type="submit">提交</button>
      <button type="reset">重置</button>
    </form>
  </div>
</body>
</html>
